<?php

/**
 * This is the model class for table "lusi_registerred_courses".
 *
 * The followings are the available columns in table 'lusi_registerred_courses':
 * @property string $id
 * @property string $member_id
 * @property string $class_id
 * @property string $registration_date
 * @property integer $is_waiting_list
 * @property integer $is_paid
 * @property integer $is_cancelled
 * @property string $total_amount
 * @property string $discount
 * @property string $total_payable
 * @property string $payment_method
 * @property string $payment_note
 *
 * The followings are the available model relations:
 * @property Classes $class
 * @property Members $member
 * @property RegistrantExtraFields[] $lusiRegistrantExtraFields
 * @property Transactions[] $transactions
 */
class RegisterredCourses extends CActiveRecord
{
	/**
	 * @var string
	 */
	public $id;

	/**
	 * @var string
	 */
	public $member_id;

	/**
	 * @var string
	 */
	public $class_id;

	/**
	 * @var string
	 */
	public $registration_date;

	/**
	 * @var integer
	 */
	public $is_waiting_list;

	/**
	 * @var integer
	 */
	public $is_paid;

	/**
	 * @var integer
	 */
	public $is_cancelled;

	/**
	 * @var string
	 */
	public $total_amount;

	/**
	 * @var string
	 */
	public $discount;

	/**
	 * @var string
	 */
	public $total_payable;

	/**
	 * @var string
	 */
	public $payment_method;

	/**
	 * @var string
	 */
	public $payment_note;


 	/**
	 * @var Classes
	 */
	 public $Classes;

 	/**
	 * @var Members
	 */
	 public $Members;

 	/**
	 * @var RegistrantExtraFields
	 */
	 public $RegistrantExtraFields;

 	/**
	 * @var Transactions
	 */
	 public $Transactions;

	/**
	 * Returns the static model of the specified AR class.
	 * @return RegisterredCourses the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'lusi_registerred_courses';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('member_id, class_id, registration_date, total_amount, discount', 'required'),
			array('is_waiting_list, is_paid, is_cancelled', 'numerical', 'integerOnly'=>true),
			array('member_id, class_id', 'length', 'max'=>11),
			array('total_amount, discount, total_payable', 'length', 'max'=>10),
			array('payment_method', 'length', 'max'=>7),
			array('payment_note', 'length', 'max'=>200),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, member_id, class_id, registration_date, is_waiting_list, is_paid, is_cancelled, total_amount, discount, total_payable, payment_method, payment_note', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'class' => array(self::BELONGS_TO, 'Classes', 'class_id'),
			'member' => array(self::BELONGS_TO, 'Members', 'member_id'),
			'lusiRegistrantExtraFields' => array(self::MANY_MANY, 'RegistrantExtraFields', 'lusi_registrant_extra_info(register_course_id, field_id)'),
			'transactions' => array(self::HAS_MANY, 'Transactions', 'registerred_course_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'member_id' => 'Member',
			'class_id' => 'Class',
			'registration_date' => 'Registration Date',
			'is_waiting_list' => 'Is Waiting List',
			'is_paid' => 'Is Paid',
			'is_cancelled' => 'Is Cancelled',
			'total_amount' => 'Total Amount',
			'discount' => 'Discount',
			'total_payable' => 'Total Payable',
			'payment_method' => 'Payment Method',
			'payment_note' => 'Payment Note',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('member_id',$this->member_id,true);
		$criteria->compare('class_id',$this->class_id,true);
		$criteria->compare('registration_date',$this->registration_date,true);
		$criteria->compare('is_waiting_list',$this->is_waiting_list);
		$criteria->compare('is_paid',$this->is_paid);
		$criteria->compare('is_cancelled',$this->is_cancelled);
		$criteria->compare('total_amount',$this->total_amount,true);
		$criteria->compare('discount',$this->discount,true);
		$criteria->compare('total_payable',$this->total_payable,true);
		$criteria->compare('payment_method',$this->payment_method,true);
		$criteria->compare('payment_note',$this->payment_note,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}